package coffee.to;

import java.sql.Date;

public class MaterialTO {
	private int materialId;		//재료ID
	private Date materialDate;	//입고일자
	private String company;		//업체명
	private int price;	//단가
	private int weight;		//중량
	private String grade;	//등급
	private double discriminationValue;	//판별식값
	private int foreignProbability;	//이물질률
	
	//no-arg 생성자
	public MaterialTO() {}
	
	//전체값 받는 생성자
	public MaterialTO(int materialId, Date materialDate, String company,
			int price, int weight, String grade, double discriminationValue,
			int foreignProbability) {
		this.materialId = materialId;
		this.materialDate = materialDate;
		this.company = company;
		this.price = price;
		this.weight = weight;
		this.grade = grade;
		this.discriminationValue = discriminationValue;
		this.foreignProbability = foreignProbability;
	}
	
	//ID를 제외한 나머지 값 받는 생성자
	public MaterialTO(Date materialDate, String company, int price, int weight,
			String grade, double discriminationValue, int foreignProbability) {
		this.materialDate = materialDate;
		this.company = company;
		this.price = price;
		this.weight = weight;
		this.grade = grade;
		this.discriminationValue = discriminationValue;
		this.foreignProbability = foreignProbability;
	}

	public int getMaterialId() {
		return materialId;
	}

	public void setMaterialId(int materialId) {
		this.materialId = materialId;
	}

	public Date getMaterialDate() {
		return materialDate;
	}

	public void setMaterialDate(Date materialDate) {
		this.materialDate = materialDate;
	}

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	public double getDiscriminationValue() {
		return discriminationValue;
	}

	public void setDiscriminationValue(double discriminationValue) {
		this.discriminationValue = discriminationValue;
	}

	public int getForeignProbability() {
		return foreignProbability;
	}

	public void setForeignProbability(int foreignProbability) {
		this.foreignProbability = foreignProbability;
	}

	@Override
	public String toString() {
		return "MaterialTO [materialId=" + materialId + ", materialDate="
				+ materialDate + ", company=" + company + ", price=" + price
				+ ", weight=" + weight + ", grade=" + grade
				+ ", discriminationValue=" + discriminationValue
				+ ", foreignProbability=" + foreignProbability + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((company == null) ? 0 : company.hashCode());
		long temp;
		temp = Double.doubleToLongBits(discriminationValue);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + foreignProbability;
		result = prime * result + ((grade == null) ? 0 : grade.hashCode());
		result = prime * result
				+ ((materialDate == null) ? 0 : materialDate.hashCode());
		result = prime * result + materialId;
		result = prime * result + price;
		result = prime * result + weight;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MaterialTO other = (MaterialTO) obj;
		if (company == null) {
			if (other.company != null)
				return false;
		} else if (!company.equals(other.company))
			return false;
		if (Double.doubleToLongBits(discriminationValue) != Double
				.doubleToLongBits(other.discriminationValue))
			return false;
		if (foreignProbability != other.foreignProbability)
			return false;
		if (grade == null) {
			if (other.grade != null)
				return false;
		} else if (!grade.equals(other.grade))
			return false;
		if (materialDate == null) {
			if (other.materialDate != null)
				return false;
		} else if (!materialDate.equals(other.materialDate))
			return false;
		if (materialId != other.materialId)
			return false;
		if (price != other.price)
			return false;
		if (weight != other.weight)
			return false;
		return true;
	}
	
	
}
